package best.driver.android.Activity.Environment;

import android.os.Bundle;
import android.widget.RadioButton;
import best.driver.android.Activity.Base.BaseActivity;
import best.driver.android.AppConfig;
import best.driver.android.R;
import best.driver.android.manager.UserInfoManager;
import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;


public class EnvironmentActivity extends BaseActivity{

    @InjectView(R.id.rb_aliyun)
    RadioButton mRbAliyun;

    @InjectView(R.id.rb_develop)
    RadioButton mRbDevelop;

    @InjectView(R.id.rb_produce)
    RadioButton mRbProduce;

    @InjectView(R.id.rb_uat)
    RadioButton mRbUat;

    @OnClick(R.id.rb_aliyun)
    protected void setAliyunEnvironment() {
        UserInfoManager.getInstance().setEnvironmentCode(AppConfig.ContextMode.TEST.ordinal());
        AppConfig.loadContextMode();
    }

    @OnClick(R.id.rb_develop)
    protected void setDevelopEnvironment() {
        UserInfoManager.getInstance().setEnvironmentCode(AppConfig.ContextMode.PRE_ONLINE.ordinal());
        AppConfig.loadContextMode();
    }

    @OnClick(R.id.rb_produce)
    protected void setProduceEnvironment() {
        UserInfoManager.getInstance().setEnvironmentCode(AppConfig.ContextMode.ONLINE.ordinal());
        AppConfig.loadContextMode();
    }

    @OnClick(R.id.rb_uat)
    protected void setUatEnvironment() {
        UserInfoManager.getInstance().setEnvironmentCode(AppConfig.ContextMode.UAT.ordinal());
        AppConfig.loadContextMode();
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setView(R.layout.activity_select_environment);
        ButterKnife.inject(this, view);
        if(UserInfoManager.getInstance().getEnvironmentCode() == AppConfig.ContextMode.TEST.ordinal()) {
            mRbAliyun.setChecked(true);
        } else if (UserInfoManager.getInstance().getEnvironmentCode() == AppConfig.ContextMode.ONLINE.ordinal()) {
            mRbProduce.setChecked(true);
        } else if (UserInfoManager.getInstance().getEnvironmentCode() == AppConfig.ContextMode.PRE_ONLINE.ordinal()) {
            mRbDevelop.setChecked(true);
        } else if (UserInfoManager.getInstance().getEnvironmentCode() == AppConfig.ContextMode.UAT.ordinal()) {
            mRbUat.setChecked(true);
        }

    }



}
